﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

namespace Sci7z
{
    public class AutoDelet
    {
        public static void deletFiles(string[] Names)
        {
            try
            {
                string str = "Clear.vbs";
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("Set ws = CreateObject(\"Wscript.Shell\")");
                builder.AppendLine("WScript.sleep 1000");
                builder.AppendLine("ws.run \"cmd /c del " + str + "\",vbhide");
                string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
                foreach (string str3 in Names)
                {
                    if (File.Exists(baseDirectory + str3))
                    {
                        builder.AppendLine("ws.run \"cmd /c del " + str3 + "\",vbhide");
                    }
                }
                SaveFile(builder.ToString(), baseDirectory + str);
                Process.Start(baseDirectory + str);
                Environment.Exit(0);
            }
            catch (Exception)
            {
            }
        }

        private static string SaveFile(string data, string filePath)
        {
            StreamWriter writer = new StreamWriter(filePath, false, Encoding.Default);
            writer.Write(data);
            writer.Close();
            writer.Dispose();
            return filePath;
        }
    }
}
